dt = 0.001;tf = 6;t = 0:dt:tf;
xa = sqrt(t) + cos(t);
T = 0.5;n = 0: tf/T;     % 建立离散自变量向量
x = sqrt(n*T) + cos(n*T);
deltax = 0.5;
xq = round(x/deltax) * deltax;
subplot(1,2,1);
plot(t,xa,':'),hold on, grid on;
plot(n*T, x, 'o');
stem(n*T, xq, 'x'),grid on
legend('连续时间信号xa','离散时间信号x','数字信号xq')
subplot(1,2,2)
stairs(n*T, xq), grid on     % 画出数字信号采样保持后恢复的连续时间信号曲线
legend('数字信号采样保持')
set(gcf, 'color', 'w')
